<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加页面</title>
    <script type="text/javascript" src="/js/vuejs-2.5.16.js"></script>
    <script type="text/javascript" src="/js/axios-0.18.0.js"></script>
</head>
<body>
    <div id="app">
        姓名：<input type="text" v-model="account.name"> <br/>
        余额：<input type="text" v-model="account.balance"> <br/>
        <button type="button" @click="update()">修改</button>
    </div>

</body>

<script>
    let vm = new Vue({
        el: "#app",
        data: {
            account:{}
        },
        methods: {
            update(){
                axios.put("/account",this.account).then(resp=>{
                    if(resp.data == "200"){
                        alert("修改")
                        window.location.href = "list.html"
                    }
                })
            },
            findById(id){
                axios.get("/account/"+id).then(resp =>{
                    console.log(resp.data)
                   this.account= resp.data
                })
            }
        },
        created(){
            console.log(location.search);
            let id = location.search.split("=")[1]
            this.findById(id)
        }
    })
</script>

</html>